package com.xdhl.fu.fi.controller;

import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.fi.repository.MGFlightNumberRepository;
import com.xdhl.fu.flight.info.api.mongodb.domain.MGFlightNumber;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 航班号控制器
 *
 * @author 朱力维
 * @time 2022/7/1 14:21
 */
@RestController
@RequestMapping("/flight-numbers")
public class FlightNumberController {

    @Resource
    private MGFlightNumberRepository flightNumberRepository;

    /**
     * 模糊查询航班号
     *
     * @return 航班号列表
     */
    @GetMapping("/{match}")
    public AjaxResult list(@PathVariable("match") String match) {
        List<MGFlightNumber> list = flightNumberRepository.findByFlightNumberLike(match);
        return AjaxResult.success(list);
    }

}
